function Set(array){
  var value = [];
  if(array instanceof Array)
  {
      value = Set.unique(array);
  }
  else
  {
       value = Array.from(arguments);
       value = Set.unique(value);

  }
  this.items=value;
//   return value;
}

// unqiue:唯一的
Set.unique=function(array){
    var result =[];
  for(i = 0 ; i < array.length ; i ++)
  {
      for ( j = i + 1 ; j < array.length ; j ++)
     {
         if(array[i] == array[j])
         {
             break;
         }
         else
         {
             if( j == array.length - 1 )
             {
               result.push(array[i]);

             }
         }
     }
  }
  result.push(array[array.length - 1])
  return result;
}
// instersection :相交
Set.prototype.instersection=function(otherset){

    // this.items 
    // otherset.items
 var result =[];
 for (i= 0 ; i < this.items.length ; i ++)
 {
     for (j = 0 ; j <this.items.length ; j ++)
     {
         if(this.items[i] == otherset.items[j])
         {
             result.push(this.items[i]);
             break;
         }
     }
 }
return new Set(result);
 
}

Set.prototype.equals=function(otherset){
    var a = this.items;
    var b = otherset.items;
    var array = a.concat(b);
   array=  Set.unique(array);
     if(array.length == this.items.length)
     {
         return true;
     }
     else
     {
         return false;
     } 
}
// union:并集
Set.prototype.union=function(otherset){
//  this.items
//  otherset.items;
   var array = this.items.concat(otherset.items);
   array =Set.unique(array);
   return array;
}
